package com.project.stream_producer.demo5.controller;

import com.project.stream_producer.demo5.conf.StringProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;

@RestController
public class ProducerController {
    @Autowired
    private StringProducer producer;


    @GetMapping("/string")
    public String string() throws ExecutionException, InterruptedException {
        for (int i = 0; i < 2; i++) {
            producer.send("test"+i);
            System.out.println(i);
        }

        return "success";
    }
}
